<?php
/*
Template Name: 在线留言
 */
    get_header();
?>
    <!-- 列表模块 -->
    <div class="main-container">
        <div class="wrap">
            <p class="page-title">在线留言</p>
            <div class="clearfix">
                <div class="main-block">
                    <?php comments_template(); ?>
                    <a id="page-go-hidden" href="javascript:;" style="display: none;">Click</a>
                </div>
                <div class="sidebar">
                <div class="notice-mod hot-article-mod floor">
                    <div class="head-type02">
                        <h2>下载专区</h2>
                        <a href="/download">更多&gt;</a>
                    </div>
                    <div class="article-main">
                    <?php
                        $queryArg = array(
                            'showposts' => 7,
                            "meta_key" => "post_views_count",
                            "orderby" => "meta_value_num",
                            "order" => "DESC",
                            "cat" => 28
                        );
                        query_posts($queryArg);
                        if (have_posts()) {
                            the_post();
                        
                    ?>
                    <div class="article-first clearfix">
                        <a class="img-block" href="<?php the_permalink(); ?>" title="">
                            <?php the_post_thumbnail(array(120, 73)); ?>
                        </a>
                        <div class="art-right">
                            <h3><a href="<?php the_permalink(); ?>" title=""><?php the_title(); ?></a></h3>
                            <p class="date"><?php the_time('Y-m-d'); ?></p>
                        </div>
                    </div>
                    <?php
                    }
                    ?>
                    <ul>
                        <?php
                        for ($i = 0; $i < 7; $i++) {
                            if (have_posts()) {
                                the_post();
                            ?>
                        <li>
                            <i></i>
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </li>
                            <?php
                            } else {
                                break;
                            }
                        }
                        ?>
                    </ul>
                </div>
                </div>
                <?php get_template_part('template-parts/sidebar-topic', get_post_format()); ?>
            </div>
            </div>
        </div>
    </div>
<?php
    get_footer();
?>
<script>
(function() {
    var pageTotal = parseInt($('.pagination-total em').text());
    $('.pagination-go').on('click', function() {
        var val = parseInt($(this).siblings('input').val());
        if (isNaN(val) || val < 1 || val > pageTotal) {
            alert('请输入1~' + pageTotal + '之间的页码数');
            return;
        }
        var href = 'http://' + location.host + '/message/comment-page-' + val + '#comments';
        location.href = href;
    }); 

    //验证码调整位置
    if ($('#captchaImgDiv').length) {
        $('#captchaImgDiv').appendTo('#verification-code');
        $('#si_captcha_code_p').prependTo('#captchaImgDiv');
        $('#si_captcha_code_p').find('label, .required').remove();
    }
})();
</script>
</body>
</html>